import { Banner } from '@libs/db/models/banner.model';
import { Controller, Get } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { ReturnModelType } from '@typegoose/typegoose';
import { Crud } from 'nestjs-mongoose-crud';
import { InjectModel } from 'nestjs-typegoose';

@Crud({
    model: Banner
})
@Controller('banners')
@ApiTags('横幅')
export class BannersController {

    constructor(
        @InjectModel(Banner) private readonly model: ReturnModelType<typeof Banner>
    ){}

    @Get('option')
    option() {
        return {
            title: '横幅管理',
            border: true,
            searchMenuSpan: 8,
            column: [
                {
                    prop: 'title',
                    label: '标题',
                    search: true
                },
                {
                    prop: 'Subtitle',
                    label: '简介'
                },
                {
                    prop: 'cover',
                    label: '封面',
                    span: 24,
                    type: 'upload',
                    listType: 'picture-img',
                    tip: '只能上传jpg/png图片，且不超过500kb',
                    action: 'http://localhost:3009/upload'
                },
                {
                    prop: 'video',
                    label: '视频',
                    span: 24,
                    type: 'upload',
                    listType: 'picture-img',
                    action: 'http://localhost:3009/upload'
                },
                {
                    prop: 'link',
                    label: '链接',
                    type: 'url',
                    dataType: 'string'
                },
            ]
        }
    }
}
